<?php

declare(strict_types=1);
/*
 * This file is part of eelly package.
 *
 * (c) eelly.com
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Eelly\SDK\Live\Api;

use Eelly\SDK\EellyClient;

/**
 *
 * @author shadonTools<localhost.shell@gmail.com>
 */
class LiveRedPacket
{
    /**
     * 支付回调处理
     *
     * @param array $relData 支付回调数据
     * @return bool
     *
     * @author chenyuhua
     * @since 2020.12.11
     */
    public function handleLiveRedPacketPayed(array $relData): bool
    {
        return EellyClient::requestJson('live/liveRedPacket', __FUNCTION__, ['relData' => $relData]);
    }

    /**
     * 根据查询条件获取冲榜红包数据
     *
     * @param array     $condition  查询条件
     * @param string    $field      查询字段
     * @param array     $extend     额外条件(按需扩展)
     * @return array
     *
     * @author chenyuhua
     * @since 2020.12.11
     */
    public function getLiveRedPacketList(array $condition, $field = 'base', $extend = []): array
    {
        return EellyClient::requestJson('live/liveRedPacket', __FUNCTION__, [
            'condition' => $condition,
            'field'     => $field,
            'extend'    => $extend,
        ]);
    }

    /**
     * @return self
     */
    public static function getInstance(): self
    {
        static $instance;
        if (null === $instance) {
            $instance = new self();
        }

        return $instance;
    }
}